{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c7370033-e883-4810-a885-9a61acae671d",
   "metadata": {},
   "source": [
    "# Get carbon intensity by country\n",
    "\n",
    "We get our carbon intensity from [Our World In Data](https://ourworldindata.org/grapher/carbon-intensity-electricity).\n",
    "\n",
    ">“Data Page: Carbon intensity of electricity generation”, part of the following publication: Hannah Ritchie, Pablo Rosado and Max Roser (2023) - “Energy”. Data adapted from Ember, Energy Institute. Retrieved from https://ourworldindata.org/grapher/carbon-intensity-electricity [online resource]\n",
    "\n",
    "The data source and processing are available on [OWID Github](https://github.com/owid/energy-data).\n",
    "\n",
    "We have to:\n",
    "1. Filter for the last available year\n",
    "1. Check if we not loose country we previously had.\n",
    "1. Keep only the data we need\n",
    "1. Export to JSON\n",
    "\n",
    "## How to run this notebook?\n",
    "\n",
    "```shell\n",
    "python3 -m venv .venv-notebook-data\n",
    "source .venv-notebook-data/bin/activate\n",
    "pip install pandas numpy ipykernel\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d13bd240-bfe2-4fe6-9e2d-45dd08e8342e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:49.935021Z",
     "start_time": "2024-09-20T14:28:49.919385Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import json"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b2f51b9e-ffb6-4ef7-822b-c0242f581dc8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:57.655277Z",
     "start_time": "2024-09-20T14:28:49.937013Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(21812, 130)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv(\"https://raw.githubusercontent.com/owid/energy-data/master/owid-energy-data.csv\")\n",
    "df.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "74078590",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:57.702292Z",
     "start_time": "2024-09-20T14:28:57.657612Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>year</th>\n",
       "      <th>iso_code</th>\n",
       "      <th>population</th>\n",
       "      <th>gdp</th>\n",
       "      <th>biofuel_cons_change_pct</th>\n",
       "      <th>biofuel_cons_change_twh</th>\n",
       "      <th>biofuel_cons_per_capita</th>\n",
       "      <th>biofuel_consumption</th>\n",
       "      <th>biofuel_elec_per_capita</th>\n",
       "      <th>...</th>\n",
       "      <th>solar_share_elec</th>\n",
       "      <th>solar_share_energy</th>\n",
       "      <th>wind_cons_change_pct</th>\n",
       "      <th>wind_cons_change_twh</th>\n",
       "      <th>wind_consumption</th>\n",
       "      <th>wind_elec_per_capita</th>\n",
       "      <th>wind_electricity</th>\n",
       "      <th>wind_energy_per_capita</th>\n",
       "      <th>wind_share_elec</th>\n",
       "      <th>wind_share_energy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>9205</th>\n",
       "      <td>India</td>\n",
       "      <td>1900</td>\n",
       "      <td>IND</td>\n",
       "      <td>2.807142e+08</td>\n",
       "      <td>2.716975e+11</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9206</th>\n",
       "      <td>India</td>\n",
       "      <td>1901</td>\n",
       "      <td>IND</td>\n",
       "      <td>2.818341e+08</td>\n",
       "      <td>2.773278e+11</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9207</th>\n",
       "      <td>India</td>\n",
       "      <td>1902</td>\n",
       "      <td>IND</td>\n",
       "      <td>2.831998e+08</td>\n",
       "      <td>3.006720e+11</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9208</th>\n",
       "      <td>India</td>\n",
       "      <td>1903</td>\n",
       "      <td>IND</td>\n",
       "      <td>2.848130e+08</td>\n",
       "      <td>3.047644e+11</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9209</th>\n",
       "      <td>India</td>\n",
       "      <td>1904</td>\n",
       "      <td>IND</td>\n",
       "      <td>2.864353e+08</td>\n",
       "      <td>3.060750e+11</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9324</th>\n",
       "      <td>India</td>\n",
       "      <td>2019</td>\n",
       "      <td>IND</td>\n",
       "      <td>1.383112e+09</td>\n",
       "      <td>9.595463e+12</td>\n",
       "      <td>23.248</td>\n",
       "      <td>2.451</td>\n",
       "      <td>9.396</td>\n",
       "      <td>12.996</td>\n",
       "      <td>22.782</td>\n",
       "      <td>...</td>\n",
       "      <td>2.852</td>\n",
       "      <td>1.309</td>\n",
       "      <td>4.979</td>\n",
       "      <td>7.327</td>\n",
       "      <td>166.895</td>\n",
       "      <td>45.774</td>\n",
       "      <td>63.31</td>\n",
       "      <td>120.666</td>\n",
       "      <td>3.903</td>\n",
       "      <td>1.791</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9325</th>\n",
       "      <td>India</td>\n",
       "      <td>2020</td>\n",
       "      <td>IND</td>\n",
       "      <td>1.396387e+09</td>\n",
       "      <td>8.945314e+12</td>\n",
       "      <td>-6.260</td>\n",
       "      <td>-0.813</td>\n",
       "      <td>8.724</td>\n",
       "      <td>12.182</td>\n",
       "      <td>23.532</td>\n",
       "      <td>...</td>\n",
       "      <td>3.709</td>\n",
       "      <td>1.746</td>\n",
       "      <td>-4.560</td>\n",
       "      <td>-8.195</td>\n",
       "      <td>158.700</td>\n",
       "      <td>43.276</td>\n",
       "      <td>60.43</td>\n",
       "      <td>113.650</td>\n",
       "      <td>3.820</td>\n",
       "      <td>1.798</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9326</th>\n",
       "      <td>India</td>\n",
       "      <td>2021</td>\n",
       "      <td>IND</td>\n",
       "      <td>1.407564e+09</td>\n",
       "      <td>9.801621e+12</td>\n",
       "      <td>61.522</td>\n",
       "      <td>7.495</td>\n",
       "      <td>13.979</td>\n",
       "      <td>19.677</td>\n",
       "      <td>26.116</td>\n",
       "      <td>...</td>\n",
       "      <td>3.984</td>\n",
       "      <td>1.865</td>\n",
       "      <td>12.688</td>\n",
       "      <td>19.481</td>\n",
       "      <td>178.181</td>\n",
       "      <td>48.374</td>\n",
       "      <td>68.09</td>\n",
       "      <td>126.588</td>\n",
       "      <td>3.971</td>\n",
       "      <td>1.859</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9327</th>\n",
       "      <td>India</td>\n",
       "      <td>2022</td>\n",
       "      <td>IND</td>\n",
       "      <td>1.417173e+09</td>\n",
       "      <td>1.047625e+13</td>\n",
       "      <td>42.380</td>\n",
       "      <td>8.339</td>\n",
       "      <td>19.769</td>\n",
       "      <td>28.016</td>\n",
       "      <td>28.747</td>\n",
       "      <td>...</td>\n",
       "      <td>5.122</td>\n",
       "      <td>2.456</td>\n",
       "      <td>2.865</td>\n",
       "      <td>4.437</td>\n",
       "      <td>182.617</td>\n",
       "      <td>49.429</td>\n",
       "      <td>70.05</td>\n",
       "      <td>128.860</td>\n",
       "      <td>3.770</td>\n",
       "      <td>1.808</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9328</th>\n",
       "      <td>India</td>\n",
       "      <td>2023</td>\n",
       "      <td>IND</td>\n",
       "      <td>1.428628e+09</td>\n",
       "      <td>NaN</td>\n",
       "      <td>22.563</td>\n",
       "      <td>6.321</td>\n",
       "      <td>24.035</td>\n",
       "      <td>34.337</td>\n",
       "      <td>27.516</td>\n",
       "      <td>...</td>\n",
       "      <td>5.763</td>\n",
       "      <td>2.718</td>\n",
       "      <td>17.219</td>\n",
       "      <td>30.667</td>\n",
       "      <td>213.285</td>\n",
       "      <td>57.468</td>\n",
       "      <td>82.10</td>\n",
       "      <td>149.293</td>\n",
       "      <td>4.172</td>\n",
       "      <td>1.968</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>124 rows × 130 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     country  year iso_code    population           gdp  \\\n",
       "9205   India  1900      IND  2.807142e+08  2.716975e+11   \n",
       "9206   India  1901      IND  2.818341e+08  2.773278e+11   \n",
       "9207   India  1902      IND  2.831998e+08  3.006720e+11   \n",
       "9208   India  1903      IND  2.848130e+08  3.047644e+11   \n",
       "9209   India  1904      IND  2.864353e+08  3.060750e+11   \n",
       "...      ...   ...      ...           ...           ...   \n",
       "9324   India  2019      IND  1.383112e+09  9.595463e+12   \n",
       "9325   India  2020      IND  1.396387e+09  8.945314e+12   \n",
       "9326   India  2021      IND  1.407564e+09  9.801621e+12   \n",
       "9327   India  2022      IND  1.417173e+09  1.047625e+13   \n",
       "9328   India  2023      IND  1.428628e+09           NaN   \n",
       "\n",
       "      biofuel_cons_change_pct  biofuel_cons_change_twh  \\\n",
       "9205                      NaN                      NaN   \n",
       "9206                      NaN                      NaN   \n",
       "9207                      NaN                      NaN   \n",
       "9208                      NaN                      NaN   \n",
       "9209                      NaN                      NaN   \n",
       "...                       ...                      ...   \n",
       "9324                   23.248                    2.451   \n",
       "9325                   -6.260                   -0.813   \n",
       "9326                   61.522                    7.495   \n",
       "9327                   42.380                    8.339   \n",
       "9328                   22.563                    6.321   \n",
       "\n",
       "      biofuel_cons_per_capita  biofuel_consumption  biofuel_elec_per_capita  \\\n",
       "9205                      NaN                  NaN                      NaN   \n",
       "9206                      NaN                  NaN                      NaN   \n",
       "9207                      NaN                  NaN                      NaN   \n",
       "9208                      NaN                  NaN                      NaN   \n",
       "9209                      NaN                  NaN                      NaN   \n",
       "...                       ...                  ...                      ...   \n",
       "9324                    9.396               12.996                   22.782   \n",
       "9325                    8.724               12.182                   23.532   \n",
       "9326                   13.979               19.677                   26.116   \n",
       "9327                   19.769               28.016                   28.747   \n",
       "9328                   24.035               34.337                   27.516   \n",
       "\n",
       "      ...  solar_share_elec  solar_share_energy  wind_cons_change_pct  \\\n",
       "9205  ...               NaN                 NaN                   NaN   \n",
       "9206  ...               NaN                 NaN                   NaN   \n",
       "9207  ...               NaN                 NaN                   NaN   \n",
       "9208  ...               NaN                 NaN                   NaN   \n",
       "9209  ...               NaN                 NaN                   NaN   \n",
       "...   ...               ...                 ...                   ...   \n",
       "9324  ...             2.852               1.309                 4.979   \n",
       "9325  ...             3.709               1.746                -4.560   \n",
       "9326  ...             3.984               1.865                12.688   \n",
       "9327  ...             5.122               2.456                 2.865   \n",
       "9328  ...             5.763               2.718                17.219   \n",
       "\n",
       "      wind_cons_change_twh  wind_consumption  wind_elec_per_capita  \\\n",
       "9205                   NaN               NaN                   NaN   \n",
       "9206                   NaN               NaN                   NaN   \n",
       "9207                   NaN               NaN                   NaN   \n",
       "9208                   NaN               NaN                   NaN   \n",
       "9209                   NaN               NaN                   NaN   \n",
       "...                    ...               ...                   ...   \n",
       "9324                 7.327           166.895                45.774   \n",
       "9325                -8.195           158.700                43.276   \n",
       "9326                19.481           178.181                48.374   \n",
       "9327                 4.437           182.617                49.429   \n",
       "9328                30.667           213.285                57.468   \n",
       "\n",
       "      wind_electricity  wind_energy_per_capita  wind_share_elec  \\\n",
       "9205               NaN                     NaN              NaN   \n",
       "9206               NaN                     NaN              NaN   \n",
       "9207               NaN                     NaN              NaN   \n",
       "9208               NaN                     NaN              NaN   \n",
       "9209               NaN                     NaN              NaN   \n",
       "...                ...                     ...              ...   \n",
       "9324             63.31                 120.666            3.903   \n",
       "9325             60.43                 113.650            3.820   \n",
       "9326             68.09                 126.588            3.971   \n",
       "9327             70.05                 128.860            3.770   \n",
       "9328             82.10                 149.293            4.172   \n",
       "\n",
       "      wind_share_energy  \n",
       "9205                NaN  \n",
       "9206                NaN  \n",
       "9207                NaN  \n",
       "9208                NaN  \n",
       "9209                NaN  \n",
       "...                 ...  \n",
       "9324              1.791  \n",
       "9325              1.798  \n",
       "9326              1.859  \n",
       "9327              1.808  \n",
       "9328              1.968  \n",
       "\n",
       "[124 rows x 130 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.query(\"country == 'India'\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e5e86f7a-7015-4b93-a2b7-74a310ea78b3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:57.718392Z",
     "start_time": "2024-09-20T14:28:57.705424Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['nuclear_electricity']"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "elec_col = [c for c in df.columns.to_list() if \"_electricity\" in c]\n",
    "nuke_col = [c for c in elec_col if \"nuclear\" in c]\n",
    "nuke_col"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "47a0ae4a-f9b8-40b8-9048-96d299871cd3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:57.734329Z",
     "start_time": "2024-09-20T14:28:57.720711Z"
    }
   },
   "outputs": [],
   "source": [
    "carbon_intensity_col = [c for c in df.columns.to_list() if \"intensity\" in c]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "a89d2199-bf06-42fa-a793-d0d3eb4070c5",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:57.765924Z",
     "start_time": "2024-09-20T14:28:57.735686Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>iso_code</th>\n",
       "      <th>year</th>\n",
       "      <th>carbon_intensity_elec</th>\n",
       "      <th>biofuel_electricity</th>\n",
       "      <th>coal_electricity</th>\n",
       "      <th>fossil_electricity</th>\n",
       "      <th>gas_electricity</th>\n",
       "      <th>hydro_electricity</th>\n",
       "      <th>low_carbon_electricity</th>\n",
       "      <th>nuclear_electricity</th>\n",
       "      <th>oil_electricity</th>\n",
       "      <th>other_renewable_electricity</th>\n",
       "      <th>other_renewable_exc_biofuel_electricity</th>\n",
       "      <th>per_capita_electricity</th>\n",
       "      <th>renewables_electricity</th>\n",
       "      <th>solar_electricity</th>\n",
       "      <th>wind_electricity</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>7502</th>\n",
       "      <td>France</td>\n",
       "      <td>FRA</td>\n",
       "      <td>2023</td>\n",
       "      <td>56.039</td>\n",
       "      <td>9.5</td>\n",
       "      <td>2.16</td>\n",
       "      <td>43.3</td>\n",
       "      <td>31.43</td>\n",
       "      <td>53.19</td>\n",
       "      <td>470.81</td>\n",
       "      <td>335.65</td>\n",
       "      <td>9.71</td>\n",
       "      <td>10.1</td>\n",
       "      <td>0.6</td>\n",
       "      <td>7939.115</td>\n",
       "      <td>135.16</td>\n",
       "      <td>23.26</td>\n",
       "      <td>48.61</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     country iso_code  year  carbon_intensity_elec  biofuel_electricity  \\\n",
       "7502  France      FRA  2023                 56.039                  9.5   \n",
       "\n",
       "      coal_electricity  fossil_electricity  gas_electricity  \\\n",
       "7502              2.16                43.3            31.43   \n",
       "\n",
       "      hydro_electricity  low_carbon_electricity  nuclear_electricity  \\\n",
       "7502              53.19                  470.81               335.65   \n",
       "\n",
       "      oil_electricity  other_renewable_electricity  \\\n",
       "7502             9.71                         10.1   \n",
       "\n",
       "      other_renewable_exc_biofuel_electricity  per_capita_electricity  \\\n",
       "7502                                      0.6                7939.115   \n",
       "\n",
       "      renewables_electricity  solar_electricity  wind_electricity  \n",
       "7502                  135.16              23.26             48.61  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "latest_year = df['year'].max()\n",
    "df[['country', 'iso_code', 'year'] + carbon_intensity_col + elec_col].query(f\"iso_code=='FRA' and year=={latest_year}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "4c5184db",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:57.812514Z",
     "start_time": "2024-09-20T14:28:57.768075Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_178936/160094593.py:27: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  df_filtered.rename(columns=columns_names, inplace=True)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country_name</th>\n",
       "      <th>iso_code</th>\n",
       "      <th>year</th>\n",
       "      <th>carbon_intensity</th>\n",
       "      <th>fossil_TWh</th>\n",
       "      <th>renewables_TWh</th>\n",
       "      <th>per_capita_Wh</th>\n",
       "      <th>coal_TWh</th>\n",
       "      <th>gas_TWh</th>\n",
       "      <th>oil_TWh</th>\n",
       "      <th>solar_TWh</th>\n",
       "      <th>wind_TWh</th>\n",
       "      <th>hydroelectricity_TWh</th>\n",
       "      <th>other_renewable_TWh</th>\n",
       "      <th>other_renewable_exc_biofuel_TWh</th>\n",
       "      <th>nuclear_TWh</th>\n",
       "      <th>biofuel_TWh</th>\n",
       "      <th>low_carbon_TWh</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>AFG</td>\n",
       "      <td>2022</td>\n",
       "      <td>132.530</td>\n",
       "      <td>0.13</td>\n",
       "      <td>0.70</td>\n",
       "      <td>20.181</td>\n",
       "      <td>0.03</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.10</td>\n",
       "      <td>0.08</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.62</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>635</th>\n",
       "      <td>Albania</td>\n",
       "      <td>ALB</td>\n",
       "      <td>2022</td>\n",
       "      <td>24.286</td>\n",
       "      <td>0.00</td>\n",
       "      <td>7.00</td>\n",
       "      <td>2462.779</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.04</td>\n",
       "      <td>0.00</td>\n",
       "      <td>6.96</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>7.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>758</th>\n",
       "      <td>Algeria</td>\n",
       "      <td>DZA</td>\n",
       "      <td>2022</td>\n",
       "      <td>634.611</td>\n",
       "      <td>87.50</td>\n",
       "      <td>0.68</td>\n",
       "      <td>1963.779</td>\n",
       "      <td>0.00</td>\n",
       "      <td>87.12</td>\n",
       "      <td>0.38</td>\n",
       "      <td>0.66</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>802</th>\n",
       "      <td>American Samoa</td>\n",
       "      <td>ASM</td>\n",
       "      <td>2022</td>\n",
       "      <td>611.111</td>\n",
       "      <td>0.17</td>\n",
       "      <td>0.01</td>\n",
       "      <td>4063.664</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.17</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>925</th>\n",
       "      <td>Angola</td>\n",
       "      <td>AGO</td>\n",
       "      <td>2022</td>\n",
       "      <td>174.734</td>\n",
       "      <td>4.23</td>\n",
       "      <td>12.71</td>\n",
       "      <td>475.990</td>\n",
       "      <td>0.00</td>\n",
       "      <td>1.67</td>\n",
       "      <td>2.56</td>\n",
       "      <td>0.02</td>\n",
       "      <td>0.00</td>\n",
       "      <td>12.64</td>\n",
       "      <td>0.05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.05</td>\n",
       "      <td>12.71</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       country_name iso_code  year  carbon_intensity  fossil_TWh  \\\n",
       "146     Afghanistan      AFG  2022           132.530        0.13   \n",
       "635         Albania      ALB  2022            24.286        0.00   \n",
       "758         Algeria      DZA  2022           634.611       87.50   \n",
       "802  American Samoa      ASM  2022           611.111        0.17   \n",
       "925          Angola      AGO  2022           174.734        4.23   \n",
       "\n",
       "     renewables_TWh  per_capita_Wh  coal_TWh  gas_TWh  oil_TWh  solar_TWh  \\\n",
       "146            0.70         20.181      0.03     0.00     0.10       0.08   \n",
       "635            7.00       2462.779      0.00     0.00     0.00       0.04   \n",
       "758            0.68       1963.779      0.00    87.12     0.38       0.66   \n",
       "802            0.01       4063.664      0.00     0.00     0.17       0.01   \n",
       "925           12.71        475.990      0.00     1.67     2.56       0.02   \n",
       "\n",
       "     wind_TWh  hydroelectricity_TWh  other_renewable_TWh  \\\n",
       "146      0.00                  0.62                 0.00   \n",
       "635      0.00                  6.96                 0.00   \n",
       "758      0.01                  0.01                 0.00   \n",
       "802      0.00                  0.00                 0.00   \n",
       "925      0.00                 12.64                 0.05   \n",
       "\n",
       "     other_renewable_exc_biofuel_TWh  nuclear_TWh  biofuel_TWh  low_carbon_TWh  \n",
       "146                              0.0          0.0         0.00            0.70  \n",
       "635                              0.0          0.0         0.00            7.00  \n",
       "758                              0.0          0.0         0.00            0.68  \n",
       "802                              0.0          0.0         0.00            0.01  \n",
       "925                              0.0          0.0         0.05           12.71  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# keeping only relevant columns\n",
    "dff = df[['country', 'iso_code', 'year'] + carbon_intensity_col + elec_col]\n",
    "# getting rid of row with na carbon intensity for electricity\n",
    "dff = dff.dropna(subset='carbon_intensity_elec')\n",
    "# keeping the most recent available row\n",
    "dff = dff.loc[dff.groupby('country')['year'].idxmax()]\n",
    "# no empty isocode\n",
    "df_filtered = dff[dff[\"iso_code\"].notna()]\n",
    "columns_names = {\n",
    "    'country':'country_name',\n",
    "    'carbon_intensity_elec':'carbon_intensity',\n",
    "    'biofuel_electricity':'biofuel_TWh',\n",
    "    'coal_electricity':'coal_TWh',\n",
    "    'fossil_electricity':'fossil_TWh',\n",
    "    'gas_electricity':'gas_TWh',\n",
    "    'hydro_electricity':'hydroelectricity_TWh',\n",
    "    'low_carbon_electricity':'low_carbon_TWh',\n",
    "    'nuclear_electricity':'nuclear_TWh',\n",
    "    'oil_electricity':'oil_TWh',\n",
    "    'other_renewable_electricity':'other_renewable_TWh',\n",
    "    'other_renewable_exc_biofuel_electricity':'other_renewable_exc_biofuel_TWh',\n",
    "    'per_capita_electricity':'per_capita_Wh',\n",
    "    'renewables_electricity':'renewables_TWh',\n",
    "    'solar_electricity':'solar_TWh',\n",
    "    'wind_electricity':'wind_TWh'\n",
    "}\n",
    "df_filtered.rename(columns=columns_names, inplace=True)\n",
    "df_filtered = df_filtered[['country_name',\n",
    "                        'iso_code',\n",
    "                        'year',\n",
    "                        'carbon_intensity',\n",
    "                        'fossil_TWh',\n",
    "                        'renewables_TWh',\n",
    "                        'per_capita_Wh',\n",
    "                        'coal_TWh',\n",
    "                        'gas_TWh',\n",
    "                        'oil_TWh',\n",
    "                        'solar_TWh',\n",
    "                        'wind_TWh',\n",
    "                        'hydroelectricity_TWh',\n",
    "                        'other_renewable_TWh',\n",
    "                        'other_renewable_exc_biofuel_TWh',\n",
    "                        'nuclear_TWh',\n",
    "                        'biofuel_TWh',\n",
    "                        'low_carbon_TWh']]\n",
    "df_filtered.head(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "1fcc8ec7",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:57.843990Z",
     "start_time": "2024-09-20T14:28:57.813881Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country_name</th>\n",
       "      <th>iso_code</th>\n",
       "      <th>year</th>\n",
       "      <th>carbon_intensity</th>\n",
       "      <th>fossil_TWh</th>\n",
       "      <th>renewables_TWh</th>\n",
       "      <th>per_capita_Wh</th>\n",
       "      <th>coal_TWh</th>\n",
       "      <th>gas_TWh</th>\n",
       "      <th>oil_TWh</th>\n",
       "      <th>solar_TWh</th>\n",
       "      <th>wind_TWh</th>\n",
       "      <th>hydroelectricity_TWh</th>\n",
       "      <th>other_renewable_TWh</th>\n",
       "      <th>other_renewable_exc_biofuel_TWh</th>\n",
       "      <th>nuclear_TWh</th>\n",
       "      <th>biofuel_TWh</th>\n",
       "      <th>low_carbon_TWh</th>\n",
       "      <th>total_TWh</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>AFG</td>\n",
       "      <td>2022</td>\n",
       "      <td>132.530</td>\n",
       "      <td>0.13</td>\n",
       "      <td>0.7</td>\n",
       "      <td>20.181</td>\n",
       "      <td>0.03</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.1</td>\n",
       "      <td>0.08</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.62</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.7</td>\n",
       "      <td>0.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>635</th>\n",
       "      <td>Albania</td>\n",
       "      <td>ALB</td>\n",
       "      <td>2022</td>\n",
       "      <td>24.286</td>\n",
       "      <td>0.00</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2462.779</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.04</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.96</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>7.00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    country_name iso_code  year  carbon_intensity  fossil_TWh  renewables_TWh  \\\n",
       "146  Afghanistan      AFG  2022           132.530        0.13             0.7   \n",
       "635      Albania      ALB  2022            24.286        0.00             7.0   \n",
       "\n",
       "     per_capita_Wh  coal_TWh  gas_TWh  oil_TWh  solar_TWh  wind_TWh  \\\n",
       "146         20.181      0.03      0.0      0.1       0.08       0.0   \n",
       "635       2462.779      0.00      0.0      0.0       0.04       0.0   \n",
       "\n",
       "     hydroelectricity_TWh  other_renewable_TWh  \\\n",
       "146                  0.62                  0.0   \n",
       "635                  6.96                  0.0   \n",
       "\n",
       "     other_renewable_exc_biofuel_TWh  nuclear_TWh  biofuel_TWh  \\\n",
       "146                              0.0          0.0          0.0   \n",
       "635                              0.0          0.0          0.0   \n",
       "\n",
       "     low_carbon_TWh  total_TWh  \n",
       "146             0.7       0.83  \n",
       "635             7.0       7.00  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "columns_to_sum = [\"fossil_TWh\", \"renewables_TWh\", \"nuclear_TWh\"]\n",
    "df_filtered['total_TWh'] = df_filtered[columns_to_sum].sum(axis=1)\n",
    "df_filtered.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e7d87abd",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:57.875083Z",
     "start_time": "2024-09-20T14:28:57.846260Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country_name</th>\n",
       "      <th>iso_code</th>\n",
       "      <th>year</th>\n",
       "      <th>carbon_intensity</th>\n",
       "      <th>fossil_TWh</th>\n",
       "      <th>renewables_TWh</th>\n",
       "      <th>per_capita_Wh</th>\n",
       "      <th>coal_TWh</th>\n",
       "      <th>gas_TWh</th>\n",
       "      <th>oil_TWh</th>\n",
       "      <th>solar_TWh</th>\n",
       "      <th>wind_TWh</th>\n",
       "      <th>hydroelectricity_TWh</th>\n",
       "      <th>other_renewable_TWh</th>\n",
       "      <th>other_renewable_exc_biofuel_TWh</th>\n",
       "      <th>nuclear_TWh</th>\n",
       "      <th>biofuel_TWh</th>\n",
       "      <th>low_carbon_TWh</th>\n",
       "      <th>total_TWh</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>7502</th>\n",
       "      <td>France</td>\n",
       "      <td>FRA</td>\n",
       "      <td>2023</td>\n",
       "      <td>56.039</td>\n",
       "      <td>43.3</td>\n",
       "      <td>135.16</td>\n",
       "      <td>7939.115</td>\n",
       "      <td>2.16</td>\n",
       "      <td>31.43</td>\n",
       "      <td>9.71</td>\n",
       "      <td>23.26</td>\n",
       "      <td>48.61</td>\n",
       "      <td>53.19</td>\n",
       "      <td>10.1</td>\n",
       "      <td>0.6</td>\n",
       "      <td>335.65</td>\n",
       "      <td>9.5</td>\n",
       "      <td>470.81</td>\n",
       "      <td>514.11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     country_name iso_code  year  carbon_intensity  fossil_TWh  \\\n",
       "7502       France      FRA  2023            56.039        43.3   \n",
       "\n",
       "      renewables_TWh  per_capita_Wh  coal_TWh  gas_TWh  oil_TWh  solar_TWh  \\\n",
       "7502          135.16       7939.115      2.16    31.43     9.71      23.26   \n",
       "\n",
       "      wind_TWh  hydroelectricity_TWh  other_renewable_TWh  \\\n",
       "7502     48.61                 53.19                 10.1   \n",
       "\n",
       "      other_renewable_exc_biofuel_TWh  nuclear_TWh  biofuel_TWh  \\\n",
       "7502                              0.6       335.65          9.5   \n",
       "\n",
       "      low_carbon_TWh  total_TWh  \n",
       "7502          470.81     514.11  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_filtered.query(\"iso_code=='ARE'\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "8c540b05",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:57.906616Z",
     "start_time": "2024-09-20T14:28:57.878686Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country_name</th>\n",
       "      <th>iso_code</th>\n",
       "      <th>year</th>\n",
       "      <th>carbon_intensity</th>\n",
       "      <th>fossil_TWh</th>\n",
       "      <th>renewables_TWh</th>\n",
       "      <th>per_capita_Wh</th>\n",
       "      <th>coal_TWh</th>\n",
       "      <th>gas_TWh</th>\n",
       "      <th>oil_TWh</th>\n",
       "      <th>solar_TWh</th>\n",
       "      <th>wind_TWh</th>\n",
       "      <th>hydroelectricity_TWh</th>\n",
       "      <th>other_renewable_TWh</th>\n",
       "      <th>other_renewable_exc_biofuel_TWh</th>\n",
       "      <th>nuclear_TWh</th>\n",
       "      <th>biofuel_TWh</th>\n",
       "      <th>low_carbon_TWh</th>\n",
       "      <th>total_TWh</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>7502</th>\n",
       "      <td>France</td>\n",
       "      <td>FRA</td>\n",
       "      <td>2023</td>\n",
       "      <td>56.039</td>\n",
       "      <td>43.3</td>\n",
       "      <td>135.16</td>\n",
       "      <td>7939.115</td>\n",
       "      <td>2.16</td>\n",
       "      <td>31.43</td>\n",
       "      <td>9.71</td>\n",
       "      <td>23.26</td>\n",
       "      <td>48.61</td>\n",
       "      <td>53.19</td>\n",
       "      <td>10.1</td>\n",
       "      <td>0.6</td>\n",
       "      <td>335.65</td>\n",
       "      <td>9.5</td>\n",
       "      <td>470.81</td>\n",
       "      <td>514.11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     country_name iso_code  year  carbon_intensity  fossil_TWh  \\\n",
       "7502       France      FRA  2023            56.039        43.3   \n",
       "\n",
       "      renewables_TWh  per_capita_Wh  coal_TWh  gas_TWh  oil_TWh  solar_TWh  \\\n",
       "7502          135.16       7939.115      2.16    31.43     9.71      23.26   \n",
       "\n",
       "      wind_TWh  hydroelectricity_TWh  other_renewable_TWh  \\\n",
       "7502     48.61                 53.19                 10.1   \n",
       "\n",
       "      other_renewable_exc_biofuel_TWh  nuclear_TWh  biofuel_TWh  \\\n",
       "7502                              0.6       335.65          9.5   \n",
       "\n",
       "      low_carbon_TWh  total_TWh  \n",
       "7502          470.81     514.11  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_filtered.query(\"iso_code=='FRA'\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9fbe26d1",
   "metadata": {},
   "source": [
    "renewables_Twh = hydroelectricity_Twh + wind_Twh + solar_Twh + other_renewable_Twh\n",
    "\n",
    "RTE 2022 Production\n",
    "\n",
    "![RTE](2023-07-07-22-40-48.png)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fb65e34b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:57.922400Z",
     "start_time": "2024-09-20T14:28:57.907797Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.float64(514.1099999999999)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# French electricity consumption in 2022 from https://ourworldindata.org/grapher/elec-mix-bar?stackMode=absolute&facet=metric&country=~FRA\n",
    "# 57 TWh fossil + 298 TWh nuclear + 116 TWh renewable = 471 TWh\n",
    "# From https://bilan-electrique-2021.rte-france.com/# we read 522 TWh for Production, but 468 TWh of consumption.\n",
    "# Here we found 470 TWh, which is pretty close.\n",
    "\n",
    "# According to https://analysesetdonnees.rte-france.com/bilan-electrique-2023/synthese\n",
    "# For 2023 in France total production is 494,7 TWh (320,4 TWh nuclear, 50.8 TWh wind, 21.6 TWh solar, 58.8 TWh hydro, 30 TWh gaz) with 50,1 TWh exported\n",
    "# The numbers is different from the one we have here : 514 TWh vs 494 TWh\n",
    "# 2023 electricity consumption in France is 438,7 TWh according to RTE\n",
    "# 2023 electricity carbon intensity in France is 32 gCO2eq per kilowatt-hour for 2023 according to RTE (5% of country emissions), versus 56 gCO2eq per kilowatt-hour in OurWorldInData !\n",
    "# It will be nice if someone could explain the difference between the two sources. Maybe the difference is due to the overseas territories of France ?\n",
    "\n",
    "df_filtered.query(\"iso_code=='FRA'\")[\"total_TWh\"].values[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "a05d9e0f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:57.953110Z",
     "start_time": "2024-09-20T14:28:57.924448Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country_name</th>\n",
       "      <th>iso_code</th>\n",
       "      <th>year</th>\n",
       "      <th>carbon_intensity</th>\n",
       "      <th>fossil_TWh</th>\n",
       "      <th>renewables_TWh</th>\n",
       "      <th>per_capita_Wh</th>\n",
       "      <th>coal_TWh</th>\n",
       "      <th>gas_TWh</th>\n",
       "      <th>oil_TWh</th>\n",
       "      <th>solar_TWh</th>\n",
       "      <th>wind_TWh</th>\n",
       "      <th>hydroelectricity_TWh</th>\n",
       "      <th>other_renewable_TWh</th>\n",
       "      <th>other_renewable_exc_biofuel_TWh</th>\n",
       "      <th>nuclear_TWh</th>\n",
       "      <th>biofuel_TWh</th>\n",
       "      <th>low_carbon_TWh</th>\n",
       "      <th>total_TWh</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>AFG</td>\n",
       "      <td>2022</td>\n",
       "      <td>132.530</td>\n",
       "      <td>0.13</td>\n",
       "      <td>0.70</td>\n",
       "      <td>20.181</td>\n",
       "      <td>0.03</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.10</td>\n",
       "      <td>0.08</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.62</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.70</td>\n",
       "      <td>0.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>635</th>\n",
       "      <td>Albania</td>\n",
       "      <td>ALB</td>\n",
       "      <td>2022</td>\n",
       "      <td>24.286</td>\n",
       "      <td>0.00</td>\n",
       "      <td>7.00</td>\n",
       "      <td>2462.779</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.04</td>\n",
       "      <td>0.00</td>\n",
       "      <td>6.96</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>7.00</td>\n",
       "      <td>7.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>758</th>\n",
       "      <td>Algeria</td>\n",
       "      <td>DZA</td>\n",
       "      <td>2022</td>\n",
       "      <td>634.611</td>\n",
       "      <td>87.50</td>\n",
       "      <td>0.68</td>\n",
       "      <td>1963.779</td>\n",
       "      <td>0.00</td>\n",
       "      <td>87.12</td>\n",
       "      <td>0.38</td>\n",
       "      <td>0.66</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.68</td>\n",
       "      <td>88.18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>802</th>\n",
       "      <td>American Samoa</td>\n",
       "      <td>ASM</td>\n",
       "      <td>2022</td>\n",
       "      <td>611.111</td>\n",
       "      <td>0.17</td>\n",
       "      <td>0.01</td>\n",
       "      <td>4063.664</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.17</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>925</th>\n",
       "      <td>Angola</td>\n",
       "      <td>AGO</td>\n",
       "      <td>2022</td>\n",
       "      <td>174.734</td>\n",
       "      <td>4.23</td>\n",
       "      <td>12.71</td>\n",
       "      <td>475.990</td>\n",
       "      <td>0.00</td>\n",
       "      <td>1.67</td>\n",
       "      <td>2.56</td>\n",
       "      <td>0.02</td>\n",
       "      <td>0.00</td>\n",
       "      <td>12.64</td>\n",
       "      <td>0.050</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.05</td>\n",
       "      <td>12.71</td>\n",
       "      <td>16.94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21112</th>\n",
       "      <td>Vietnam</td>\n",
       "      <td>VNM</td>\n",
       "      <td>2023</td>\n",
       "      <td>475.449</td>\n",
       "      <td>153.14</td>\n",
       "      <td>112.63</td>\n",
       "      <td>2688.376</td>\n",
       "      <td>124.31</td>\n",
       "      <td>26.52</td>\n",
       "      <td>2.31</td>\n",
       "      <td>25.46</td>\n",
       "      <td>10.02</td>\n",
       "      <td>76.79</td>\n",
       "      <td>0.853</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.36</td>\n",
       "      <td>112.63</td>\n",
       "      <td>265.77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21291</th>\n",
       "      <td>Western Sahara</td>\n",
       "      <td>ESH</td>\n",
       "      <td>2009</td>\n",
       "      <td>666.667</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.00</td>\n",
       "      <td>226.177</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21470</th>\n",
       "      <td>Yemen</td>\n",
       "      <td>YEM</td>\n",
       "      <td>2022</td>\n",
       "      <td>566.102</td>\n",
       "      <td>2.35</td>\n",
       "      <td>0.60</td>\n",
       "      <td>87.546</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.54</td>\n",
       "      <td>1.81</td>\n",
       "      <td>0.60</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.60</td>\n",
       "      <td>2.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21686</th>\n",
       "      <td>Zambia</td>\n",
       "      <td>ZMB</td>\n",
       "      <td>2022</td>\n",
       "      <td>111.967</td>\n",
       "      <td>2.16</td>\n",
       "      <td>17.31</td>\n",
       "      <td>972.641</td>\n",
       "      <td>2.16</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.14</td>\n",
       "      <td>0.00</td>\n",
       "      <td>17.09</td>\n",
       "      <td>0.080</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.08</td>\n",
       "      <td>17.31</td>\n",
       "      <td>19.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21810</th>\n",
       "      <td>Zimbabwe</td>\n",
       "      <td>ZWE</td>\n",
       "      <td>2022</td>\n",
       "      <td>297.872</td>\n",
       "      <td>2.92</td>\n",
       "      <td>6.01</td>\n",
       "      <td>547.163</td>\n",
       "      <td>2.92</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.03</td>\n",
       "      <td>0.00</td>\n",
       "      <td>5.88</td>\n",
       "      <td>0.100</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.10</td>\n",
       "      <td>6.01</td>\n",
       "      <td>8.93</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>213 rows × 19 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         country_name iso_code  year  carbon_intensity  fossil_TWh  \\\n",
       "146       Afghanistan      AFG  2022           132.530        0.13   \n",
       "635           Albania      ALB  2022            24.286        0.00   \n",
       "758           Algeria      DZA  2022           634.611       87.50   \n",
       "802    American Samoa      ASM  2022           611.111        0.17   \n",
       "925            Angola      AGO  2022           174.734        4.23   \n",
       "...               ...      ...   ...               ...         ...   \n",
       "21112         Vietnam      VNM  2023           475.449      153.14   \n",
       "21291  Western Sahara      ESH  2009           666.667        0.09   \n",
       "21470           Yemen      YEM  2022           566.102        2.35   \n",
       "21686          Zambia      ZMB  2022           111.967        2.16   \n",
       "21810        Zimbabwe      ZWE  2022           297.872        2.92   \n",
       "\n",
       "       renewables_TWh  per_capita_Wh  coal_TWh  gas_TWh  oil_TWh  solar_TWh  \\\n",
       "146              0.70         20.181      0.03     0.00     0.10       0.08   \n",
       "635              7.00       2462.779      0.00     0.00     0.00       0.04   \n",
       "758              0.68       1963.779      0.00    87.12     0.38       0.66   \n",
       "802              0.01       4063.664      0.00     0.00     0.17       0.01   \n",
       "925             12.71        475.990      0.00     1.67     2.56       0.02   \n",
       "...               ...            ...       ...      ...      ...        ...   \n",
       "21112          112.63       2688.376    124.31    26.52     2.31      25.46   \n",
       "21291            0.00        226.177      0.00     0.00     0.09       0.00   \n",
       "21470            0.60         87.546      0.00     0.54     1.81       0.60   \n",
       "21686           17.31        972.641      2.16     0.00     0.00       0.14   \n",
       "21810            6.01        547.163      2.92     0.00     0.00       0.03   \n",
       "\n",
       "       wind_TWh  hydroelectricity_TWh  other_renewable_TWh  \\\n",
       "146        0.00                  0.62                0.000   \n",
       "635        0.00                  6.96                0.000   \n",
       "758        0.01                  0.01                0.000   \n",
       "802        0.00                  0.00                0.000   \n",
       "925        0.00                 12.64                0.050   \n",
       "...         ...                   ...                  ...   \n",
       "21112     10.02                 76.79                0.853   \n",
       "21291      0.00                  0.00                0.000   \n",
       "21470      0.00                  0.00                0.000   \n",
       "21686      0.00                 17.09                0.080   \n",
       "21810      0.00                  5.88                0.100   \n",
       "\n",
       "       other_renewable_exc_biofuel_TWh  nuclear_TWh  biofuel_TWh  \\\n",
       "146                                0.0          0.0         0.00   \n",
       "635                                0.0          0.0         0.00   \n",
       "758                                0.0          0.0         0.00   \n",
       "802                                0.0          0.0         0.00   \n",
       "925                                0.0          0.0         0.05   \n",
       "...                                ...          ...          ...   \n",
       "21112                              NaN          0.0         0.36   \n",
       "21291                              0.0          0.0         0.00   \n",
       "21470                              0.0          0.0         0.00   \n",
       "21686                              0.0          0.0         0.08   \n",
       "21810                              0.0          0.0         0.10   \n",
       "\n",
       "       low_carbon_TWh  total_TWh  \n",
       "146              0.70       0.83  \n",
       "635              7.00       7.00  \n",
       "758              0.68      88.18  \n",
       "802              0.01       0.18  \n",
       "925             12.71      16.94  \n",
       "...               ...        ...  \n",
       "21112          112.63     265.77  \n",
       "21291            0.00       0.09  \n",
       "21470            0.60       2.95  \n",
       "21686           17.31      19.47  \n",
       "21810            6.01       8.93  \n",
       "\n",
       "[213 rows x 19 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_filtered"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "81dcd0fc",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:58.446123Z",
     "start_time": "2024-09-20T14:28:57.954231Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Missing carbon_intensity for 0 countries over 213.\n"
     ]
    }
   ],
   "source": [
    "energy_mix = {}\n",
    "missings = []\n",
    "for code in df_filtered['iso_code'].unique():\n",
    "#for code in ['FRA', 'AFG', 'VNM']:\n",
    "    # print(code)\n",
    "    df=df_filtered.query(\"iso_code == @code\")\n",
    "    max_year = df.year.max()\n",
    "    #if df.isnull().values.any() == False:\n",
    "    if len(df)>0 and not np.isnan(df.loc[df.year == max_year].iloc[0][\"carbon_intensity\"]):\n",
    "        energy_mix[code]=df.loc[df.year == max_year].iloc[0].replace(np.nan, 0).to_dict()\n",
    "    else:\n",
    "        missings.append(code)\n",
    "print(f\"Missing carbon_intensity for {len(missings)} countries over {len(df_filtered)}.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "39d531e9",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:28:58.461786Z",
     "start_time": "2024-09-20T14:28:58.448118Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['AFG', 'ALB', 'DZA', 'ASM', 'AGO', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BIH', 'BWA', 'BRA', 'VGB', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'COL', 'COM', 'COG', 'COK', 'CRI', 'CIV', 'HRV', 'CUB', 'CYP', 'CZE', 'COD', 'DNK', 'DJI', 'DMA', 'DOM', 'TLS', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'SWZ', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN', 'FRA', 'GUF', 'PYF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM', 'GTM', 'GIN', 'GNB', 'GUY', 'HTI', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN', 'IRQ', 'IRL', 'ISR', 'ITA', 'JAM', 'JPN', 'JOR', 'KAZ', 'KEN', 'KIR', 'KWT', 'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LTU', 'LUX', 'MAC', 'MDG', 'MWI', 'MYS', 'MDV', 'MLI', 'MLT', 'MTQ', 'MRT', 'MUS', 'MEX', 'MDA', 'MNG', 'MNE', 'MSR', 'MAR', 'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'PRK', 'MKD', 'NOR', 'OMN', 'PAK', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'POL', 'PRT', 'PRI', 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'SHN', 'KNA', 'LCA', 'SPM', 'VCT', 'WSM', 'STP', 'SAU', 'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'KOR', 'SSD', 'ESP', 'LKA', 'SDN', 'SUR', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TGO', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'VIR', 'URY', 'UZB', 'VUT', 'VEN', 'VNM', 'ESH', 'YEM', 'ZMB', 'ZWE'])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "energy_mix.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "0533388d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:29:55.272147Z",
     "start_time": "2024-09-20T14:29:55.224753Z"
    }
   },
   "outputs": [],
   "source": [
    "with open(\"global_energy_mix.json\", \"w\") as outfile:\n",
    "    json.dump(energy_mix, outfile, indent=4, sort_keys=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "7115b52c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:30:02.911991Z",
     "start_time": "2024-09-20T14:30:02.897462Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "213"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(energy_mix.keys())\n",
    "# 213 countries with keeping also old data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "dbf33ab5",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:31:19.805358Z",
     "start_time": "2024-09-20T14:31:19.775902Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country_name</th>\n",
       "      <th>iso_code</th>\n",
       "      <th>year</th>\n",
       "      <th>carbon_intensity</th>\n",
       "      <th>fossil_TWh</th>\n",
       "      <th>renewables_TWh</th>\n",
       "      <th>per_capita_Wh</th>\n",
       "      <th>coal_TWh</th>\n",
       "      <th>gas_TWh</th>\n",
       "      <th>oil_TWh</th>\n",
       "      <th>solar_TWh</th>\n",
       "      <th>wind_TWh</th>\n",
       "      <th>hydroelectricity_TWh</th>\n",
       "      <th>other_renewable_TWh</th>\n",
       "      <th>other_renewable_exc_biofuel_TWh</th>\n",
       "      <th>nuclear_TWh</th>\n",
       "      <th>biofuel_TWh</th>\n",
       "      <th>low_carbon_TWh</th>\n",
       "      <th>total_TWh</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>7544</th>\n",
       "      <td>French Guiana</td>\n",
       "      <td>GUF</td>\n",
       "      <td>2021</td>\n",
       "      <td>217.822</td>\n",
       "      <td>0.31</td>\n",
       "      <td>0.70</td>\n",
       "      <td>3395.392</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.31</td>\n",
       "      <td>0.06</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.59</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.05</td>\n",
       "      <td>0.70</td>\n",
       "      <td>1.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8456</th>\n",
       "      <td>Guadeloupe</td>\n",
       "      <td>GLP</td>\n",
       "      <td>2021</td>\n",
       "      <td>500.000</td>\n",
       "      <td>1.10</td>\n",
       "      <td>0.56</td>\n",
       "      <td>4191.316</td>\n",
       "      <td>0.23</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.87</td>\n",
       "      <td>0.11</td>\n",
       "      <td>0.11</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.33</td>\n",
       "      <td>0.08</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.56</td>\n",
       "      <td>1.66</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11798</th>\n",
       "      <td>Martinique</td>\n",
       "      <td>MTQ</td>\n",
       "      <td>2021</td>\n",
       "      <td>523.179</td>\n",
       "      <td>1.12</td>\n",
       "      <td>0.39</td>\n",
       "      <td>4094.371</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.12</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.05</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.00</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.39</td>\n",
       "      <td>1.51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16553</th>\n",
       "      <td>Reunion</td>\n",
       "      <td>REU</td>\n",
       "      <td>2021</td>\n",
       "      <td>572.816</td>\n",
       "      <td>2.22</td>\n",
       "      <td>0.87</td>\n",
       "      <td>3198.321</td>\n",
       "      <td>0.93</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.29</td>\n",
       "      <td>0.27</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.36</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.24</td>\n",
       "      <td>0.87</td>\n",
       "      <td>3.09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21291</th>\n",
       "      <td>Western Sahara</td>\n",
       "      <td>ESH</td>\n",
       "      <td>2009</td>\n",
       "      <td>666.667</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.00</td>\n",
       "      <td>226.177</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.09</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         country_name iso_code  year  carbon_intensity  fossil_TWh  \\\n",
       "7544    French Guiana      GUF  2021           217.822        0.31   \n",
       "8456       Guadeloupe      GLP  2021           500.000        1.10   \n",
       "11798      Martinique      MTQ  2021           523.179        1.12   \n",
       "16553         Reunion      REU  2021           572.816        2.22   \n",
       "21291  Western Sahara      ESH  2009           666.667        0.09   \n",
       "\n",
       "       renewables_TWh  per_capita_Wh  coal_TWh  gas_TWh  oil_TWh  solar_TWh  \\\n",
       "7544             0.70       3395.392       NaN      NaN     0.31       0.06   \n",
       "8456             0.56       4191.316      0.23      NaN     0.87       0.11   \n",
       "11798            0.39       4094.371       NaN      NaN     1.12       0.09   \n",
       "16553            0.87       3198.321      0.93      NaN     1.29       0.27   \n",
       "21291            0.00        226.177      0.00      0.0     0.09       0.00   \n",
       "\n",
       "       wind_TWh  hydroelectricity_TWh  other_renewable_TWh  \\\n",
       "7544        NaN                  0.59                  NaN   \n",
       "8456       0.11                  0.01                 0.33   \n",
       "11798      0.05                   NaN                 0.25   \n",
       "16553      0.00                  0.36                  NaN   \n",
       "21291      0.00                  0.00                 0.00   \n",
       "\n",
       "       other_renewable_exc_biofuel_TWh  nuclear_TWh  biofuel_TWh  \\\n",
       "7544                               NaN          NaN         0.05   \n",
       "8456                              0.08          NaN         0.25   \n",
       "11798                             0.00          NaN         0.25   \n",
       "16553                              NaN          NaN         0.24   \n",
       "21291                             0.00          0.0         0.00   \n",
       "\n",
       "       low_carbon_TWh  total_TWh  \n",
       "7544             0.70       1.01  \n",
       "8456             0.56       1.66  \n",
       "11798            0.39       1.51  \n",
       "16553            0.87       3.09  \n",
       "21291            0.00       0.09  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_filtered[df_filtered[\"year\"]<2022]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "7032a8f3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-20T14:33:45.143847Z",
     "start_time": "2024-09-20T14:33:45.097422Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country_name</th>\n",
       "      <th>iso_code</th>\n",
       "      <th>year</th>\n",
       "      <th>carbon_intensity</th>\n",
       "      <th>fossil_TWh</th>\n",
       "      <th>renewables_TWh</th>\n",
       "      <th>per_capita_Wh</th>\n",
       "      <th>coal_TWh</th>\n",
       "      <th>gas_TWh</th>\n",
       "      <th>oil_TWh</th>\n",
       "      <th>solar_TWh</th>\n",
       "      <th>wind_TWh</th>\n",
       "      <th>hydroelectricity_TWh</th>\n",
       "      <th>other_renewable_TWh</th>\n",
       "      <th>other_renewable_exc_biofuel_TWh</th>\n",
       "      <th>nuclear_TWh</th>\n",
       "      <th>biofuel_TWh</th>\n",
       "      <th>low_carbon_TWh</th>\n",
       "      <th>total_TWh</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>AFG</td>\n",
       "      <td>2022</td>\n",
       "      <td>132.530</td>\n",
       "      <td>0.13</td>\n",
       "      <td>0.70</td>\n",
       "      <td>20.181</td>\n",
       "      <td>0.03</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.10</td>\n",
       "      <td>0.08</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.62</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.70</td>\n",
       "      <td>0.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>635</th>\n",
       "      <td>Albania</td>\n",
       "      <td>ALB</td>\n",
       "      <td>2022</td>\n",
       "      <td>24.286</td>\n",
       "      <td>0.00</td>\n",
       "      <td>7.00</td>\n",
       "      <td>2462.779</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.04</td>\n",
       "      <td>0.00</td>\n",
       "      <td>6.96</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>7.00</td>\n",
       "      <td>7.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>758</th>\n",
       "      <td>Algeria</td>\n",
       "      <td>DZA</td>\n",
       "      <td>2022</td>\n",
       "      <td>634.611</td>\n",
       "      <td>87.50</td>\n",
       "      <td>0.68</td>\n",
       "      <td>1963.779</td>\n",
       "      <td>0.00</td>\n",
       "      <td>87.12</td>\n",
       "      <td>0.38</td>\n",
       "      <td>0.66</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.68</td>\n",
       "      <td>88.18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>802</th>\n",
       "      <td>American Samoa</td>\n",
       "      <td>ASM</td>\n",
       "      <td>2022</td>\n",
       "      <td>611.111</td>\n",
       "      <td>0.17</td>\n",
       "      <td>0.01</td>\n",
       "      <td>4063.664</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.17</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>925</th>\n",
       "      <td>Angola</td>\n",
       "      <td>AGO</td>\n",
       "      <td>2022</td>\n",
       "      <td>174.734</td>\n",
       "      <td>4.23</td>\n",
       "      <td>12.71</td>\n",
       "      <td>475.990</td>\n",
       "      <td>0.00</td>\n",
       "      <td>1.67</td>\n",
       "      <td>2.56</td>\n",
       "      <td>0.02</td>\n",
       "      <td>0.00</td>\n",
       "      <td>12.64</td>\n",
       "      <td>0.05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.05</td>\n",
       "      <td>12.71</td>\n",
       "      <td>16.94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20987</th>\n",
       "      <td>Venezuela</td>\n",
       "      <td>VEN</td>\n",
       "      <td>2022</td>\n",
       "      <td>185.802</td>\n",
       "      <td>18.88</td>\n",
       "      <td>65.78</td>\n",
       "      <td>2991.340</td>\n",
       "      <td>0.00</td>\n",
       "      <td>13.25</td>\n",
       "      <td>5.63</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.09</td>\n",
       "      <td>65.68</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>65.78</td>\n",
       "      <td>84.66</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21291</th>\n",
       "      <td>Western Sahara</td>\n",
       "      <td>ESH</td>\n",
       "      <td>2009</td>\n",
       "      <td>666.667</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.00</td>\n",
       "      <td>226.177</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21470</th>\n",
       "      <td>Yemen</td>\n",
       "      <td>YEM</td>\n",
       "      <td>2022</td>\n",
       "      <td>566.102</td>\n",
       "      <td>2.35</td>\n",
       "      <td>0.60</td>\n",
       "      <td>87.546</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.54</td>\n",
       "      <td>1.81</td>\n",
       "      <td>0.60</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.60</td>\n",
       "      <td>2.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21686</th>\n",
       "      <td>Zambia</td>\n",
       "      <td>ZMB</td>\n",
       "      <td>2022</td>\n",
       "      <td>111.967</td>\n",
       "      <td>2.16</td>\n",
       "      <td>17.31</td>\n",
       "      <td>972.641</td>\n",
       "      <td>2.16</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.14</td>\n",
       "      <td>0.00</td>\n",
       "      <td>17.09</td>\n",
       "      <td>0.08</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.08</td>\n",
       "      <td>17.31</td>\n",
       "      <td>19.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21810</th>\n",
       "      <td>Zimbabwe</td>\n",
       "      <td>ZWE</td>\n",
       "      <td>2022</td>\n",
       "      <td>297.872</td>\n",
       "      <td>2.92</td>\n",
       "      <td>6.01</td>\n",
       "      <td>547.163</td>\n",
       "      <td>2.92</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.03</td>\n",
       "      <td>0.00</td>\n",
       "      <td>5.88</td>\n",
       "      <td>0.10</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.10</td>\n",
       "      <td>6.01</td>\n",
       "      <td>8.93</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>135 rows × 19 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         country_name iso_code  year  carbon_intensity  fossil_TWh  \\\n",
       "146       Afghanistan      AFG  2022           132.530        0.13   \n",
       "635           Albania      ALB  2022            24.286        0.00   \n",
       "758           Algeria      DZA  2022           634.611       87.50   \n",
       "802    American Samoa      ASM  2022           611.111        0.17   \n",
       "925            Angola      AGO  2022           174.734        4.23   \n",
       "...               ...      ...   ...               ...         ...   \n",
       "20987       Venezuela      VEN  2022           185.802       18.88   \n",
       "21291  Western Sahara      ESH  2009           666.667        0.09   \n",
       "21470           Yemen      YEM  2022           566.102        2.35   \n",
       "21686          Zambia      ZMB  2022           111.967        2.16   \n",
       "21810        Zimbabwe      ZWE  2022           297.872        2.92   \n",
       "\n",
       "       renewables_TWh  per_capita_Wh  coal_TWh  gas_TWh  oil_TWh  solar_TWh  \\\n",
       "146              0.70         20.181      0.03     0.00     0.10       0.08   \n",
       "635              7.00       2462.779      0.00     0.00     0.00       0.04   \n",
       "758              0.68       1963.779      0.00    87.12     0.38       0.66   \n",
       "802              0.01       4063.664      0.00     0.00     0.17       0.01   \n",
       "925             12.71        475.990      0.00     1.67     2.56       0.02   \n",
       "...               ...            ...       ...      ...      ...        ...   \n",
       "20987           65.78       2991.340      0.00    13.25     5.63       0.01   \n",
       "21291            0.00        226.177      0.00     0.00     0.09       0.00   \n",
       "21470            0.60         87.546      0.00     0.54     1.81       0.60   \n",
       "21686           17.31        972.641      2.16     0.00     0.00       0.14   \n",
       "21810            6.01        547.163      2.92     0.00     0.00       0.03   \n",
       "\n",
       "       wind_TWh  hydroelectricity_TWh  other_renewable_TWh  \\\n",
       "146        0.00                  0.62                 0.00   \n",
       "635        0.00                  6.96                 0.00   \n",
       "758        0.01                  0.01                 0.00   \n",
       "802        0.00                  0.00                 0.00   \n",
       "925        0.00                 12.64                 0.05   \n",
       "...         ...                   ...                  ...   \n",
       "20987      0.09                 65.68                 0.00   \n",
       "21291      0.00                  0.00                 0.00   \n",
       "21470      0.00                  0.00                 0.00   \n",
       "21686      0.00                 17.09                 0.08   \n",
       "21810      0.00                  5.88                 0.10   \n",
       "\n",
       "       other_renewable_exc_biofuel_TWh  nuclear_TWh  biofuel_TWh  \\\n",
       "146                                0.0          0.0         0.00   \n",
       "635                                0.0          0.0         0.00   \n",
       "758                                0.0          0.0         0.00   \n",
       "802                                0.0          0.0         0.00   \n",
       "925                                0.0          0.0         0.05   \n",
       "...                                ...          ...          ...   \n",
       "20987                              0.0          0.0         0.00   \n",
       "21291                              0.0          0.0         0.00   \n",
       "21470                              0.0          0.0         0.00   \n",
       "21686                              0.0          0.0         0.08   \n",
       "21810                              0.0          0.0         0.10   \n",
       "\n",
       "       low_carbon_TWh  total_TWh  \n",
       "146              0.70       0.83  \n",
       "635              7.00       7.00  \n",
       "758              0.68      88.18  \n",
       "802              0.01       0.18  \n",
       "925             12.71      16.94  \n",
       "...               ...        ...  \n",
       "20987           65.78      84.66  \n",
       "21291            0.00       0.09  \n",
       "21470            0.60       2.95  \n",
       "21686           17.31      19.47  \n",
       "21810            6.01       8.93  \n",
       "\n",
       "[135 rows x 19 columns]"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_filtered[df_filtered[\"year\"]<2023]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "e99458ac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country_name</th>\n",
       "      <th>iso_code</th>\n",
       "      <th>year</th>\n",
       "      <th>carbon_intensity</th>\n",
       "      <th>fossil_TWh</th>\n",
       "      <th>renewables_TWh</th>\n",
       "      <th>per_capita_Wh</th>\n",
       "      <th>coal_TWh</th>\n",
       "      <th>gas_TWh</th>\n",
       "      <th>oil_TWh</th>\n",
       "      <th>solar_TWh</th>\n",
       "      <th>wind_TWh</th>\n",
       "      <th>hydroelectricity_TWh</th>\n",
       "      <th>other_renewable_TWh</th>\n",
       "      <th>other_renewable_exc_biofuel_TWh</th>\n",
       "      <th>nuclear_TWh</th>\n",
       "      <th>biofuel_TWh</th>\n",
       "      <th>low_carbon_TWh</th>\n",
       "      <th>total_TWh</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>7958</th>\n",
       "      <td>Germany</td>\n",
       "      <td>DEU</td>\n",
       "      <td>2023</td>\n",
       "      <td>380.95</td>\n",
       "      <td>231.48</td>\n",
       "      <td>264.56</td>\n",
       "      <td>6060.295</td>\n",
       "      <td>135.35</td>\n",
       "      <td>76.0</td>\n",
       "      <td>20.13</td>\n",
       "      <td>61.56</td>\n",
       "      <td>137.29</td>\n",
       "      <td>19.48</td>\n",
       "      <td>46.23</td>\n",
       "      <td>0.21</td>\n",
       "      <td>8.75</td>\n",
       "      <td>46.02</td>\n",
       "      <td>273.31</td>\n",
       "      <td>504.79</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     country_name iso_code  year  carbon_intensity  fossil_TWh  \\\n",
       "7958      Germany      DEU  2023            380.95      231.48   \n",
       "\n",
       "      renewables_TWh  per_capita_Wh  coal_TWh  gas_TWh  oil_TWh  solar_TWh  \\\n",
       "7958          264.56       6060.295    135.35     76.0    20.13      61.56   \n",
       "\n",
       "      wind_TWh  hydroelectricity_TWh  other_renewable_TWh  \\\n",
       "7958    137.29                 19.48                46.23   \n",
       "\n",
       "      other_renewable_exc_biofuel_TWh  nuclear_TWh  biofuel_TWh  \\\n",
       "7958                             0.21         8.75        46.02   \n",
       "\n",
       "      low_carbon_TWh  total_TWh  \n",
       "7958          273.31     504.79  "
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_filtered.query(\"iso_code=='DEU'\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ccfad132",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "hide_input": false,
  "kernelspec": {
   "display_name": ".venv-notebook-data",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
